package com.bjpowernode.controllers;

import com.bjpowernode.entities.TClueRemark;
import com.bjpowernode.querys.ClueRemarkQuery;
import com.bjpowernode.result.Result;
import com.bjpowernode.services.ClueRemarkService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ClueRemarkController {
    @Resource
    private ClueRemarkService clueRemarkService;

    @GetMapping(value = "/api/clue/{clueId}/remarks")
    public Result getClueRemarksByPage(@PathVariable(value = "clueId") Integer clueId,
                                       @RequestParam(value = "current") Integer current) {
        PageInfo<TClueRemark> pageInfo = clueRemarkService.getClueRemarkByPage(current, clueId);
        return Result.OK(pageInfo);
    }

    @PostMapping(value = "/api/clue/remark")
    public Result addClueRemark(@RequestBody ClueRemarkQuery clueRemarkQuery) {
        int save = clueRemarkService.addClueRemark(clueRemarkQuery);
        return save >= 1 ? Result.OK() : Result.FAIL();
    }
}
